package net.xdclass.coupon.controller;


import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import net.xdclass.common.JsonData;
import net.xdclass.coupon.service.CouponRecordService;
import net.xdclass.coupon.vo.CouponRecordVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author yanghuanxi
 * @since 2023-12-05
 */
@Api(tags = "优惠券记录")
@RestController
@RequestMapping("/api/coupon_record/v1")
public class CouponRecordController {

    @Autowired
    private CouponRecordService couponRecordService;

    @ApiOperation("分页查询优惠券列表")
    @GetMapping("/page")
    public JsonData pageCouponRecord(@ApiParam("当前页") @RequestParam(value = "page", defaultValue = "1", required = false) int page,
                               @ApiParam("页大小") @RequestParam(value = "size", defaultValue = "10", required = false) int size){
        return couponRecordService.page(page, size);
    }

    @ApiOperation("查询优惠券详情")
    @GetMapping("/detail/{id}")
    public JsonData recordDetail(@ApiParam("优惠券记录id") @PathVariable(value = "id") Long recordId){
        CouponRecordVO vo = couponRecordService.selectById(recordId);
        return JsonData.buildSuccess(vo);
    }

}

